/*
 * NetworkManager.h
 *
 *  Created on:
 *      Author: rafa
 */

#ifndef NETWORKMANAGER_H_
#define NETWORKMANAGER_H_

#include <stdlib.h>

#include "../network/network.h"
#include "../network/server_network.h"

#include <SDL/SDL_net.h>

#define SERVER 	0
#define CLIENT 	1

#define PORTA		2200


class NetworkManager{

public:

	NetworkManager(int tipo);
	virtual ~NetworkManager();

	/*cliente*/
	int conectClient(const char * host);
	int sendMessage(void *buf, size_t size, size_t *bytes);
	int receive(void *buf, size_t max_size, size_t *bytes);
	int close();

	/*servidor */
	int accept();
	int close(int socket_num);

	int receive(void *buf, size_t max_size, TCPsocket *socket, size_t *bytes);
	int broadcast(void *buf, size_t size);


private:

	server_network *server;
	network *network;
};


#endif /* NETWORKMANAGER_H_ */
